package com.lele.enums;

public enum RetCode {
    /**
     * 定义默认成功code
     */
    OK(200, "操作成功"),

    /**
     * 定义默认错误code
     */
    FAIL(-1, "操作失败"),

    /**
     * 异常错误code
     */
    ERROR(500, "系统异常");


    public int retCode;
    public String retMsg;

    RetCode(int retCode, String retMsg) {
        this.retCode = retCode;
        this.retMsg = retMsg;
    }

    public int getRetCode() {
        return retCode;
    }

    public String getRetMsg() {
        return retMsg;
    }

    public static String getRetMsg(int retCode) {
        RetCode[] responseConstants = RetCode.values();
        for (RetCode ret : responseConstants) {
            if (ret.getRetCode() == retCode) {
                return ret.getRetMsg();
            }
        }
        return "";
    }
}
